'use server';

import './style.scss';
import { notFound } from 'next/navigation';
import { fetchDocument } from '@/lib/api/page/document';

export default async function DocumentPage({ params }: { params: Promise<{ code: string }> }) {
	const { code } = await params;

	const result = await fetchDocument(code);

	if (!result.success || !result.data) {
		return notFound();
	}

	const doc = result.data;

	return (
		<>
			<article id='docs'>
				<h1>{doc.subject}</h1>
				{doc.content && (
					<section dangerouslySetInnerHTML={{ __html: doc.content }} className='pb-10'/>
				)}
			</article>
		</>
	);
}